import { AttrType } from "../../attr/AttrType";
import { BuffData } from "../../buff/const/BuffData";
import { EventId } from "../../event/EventId";
import EventMgr from "../../event/EventMgr";
import { BattleRole } from "../../role/BattleRole";
import { BuffDamageResult, ITriggerResult } from "../../trigger/const/ITriggerResult";
import { EffectBase } from "../EffectBase";

/**
 * 非攻击伤害效果-流血-中毒
 */
export class DotDamageEffect extends EffectBase {
    excute(args: { target: BattleRole, buffData: BuffData }): void {

        let target = args.target;
        let attrVal = target.attrMgr.getAttr(this.params.attrType);
        let damage = attrVal * this.params.value >> 0;
        target.attrMgr.updateAttr(this.params.attrType, -damage);
        console.log("受到buff伤害:" + damage)
        let result: BuffDamageResult = {
            resultType: "buffDamage",
            target: target,
            damage: damage,
            buffId: args.buffData.buffId,
            buffType: args.buffData.buffType
        }
        //创建action
        EventMgr.ins.event(EventId.TRIGGER_RESULT, result)
    }

    get params(): { attrType: AttrType, value: number } {
        return this._params
    }
}